﻿using UnityEngine;
using System.Collections;

public class Player : MonoBehaviour
{
	public float velocity;

	public int lifes;
	public int point;

	public GameObject shoot;


	void Update ()
	{
		if(Input.GetKey(KeyCode.RightArrow))
		{
			transform.Translate(velocity * Time.deltaTime, 0, 0);
			transform.localScale = new Vector3(0.2f,0.2f,1);
		}

		if(Input.GetKey(KeyCode.LeftArrow))
		{
			transform.Translate(-velocity * Time.deltaTime, 0, 0);
			transform.localScale = new Vector3(-0.2f,0.2f,1);
		}

		if(Input.GetKey(KeyCode.UpArrow))
		{
			transform.Translate(0, velocity * Time.deltaTime, 0);
		}

		if(Input.GetKey(KeyCode.DownArrow))
		{
			transform.Translate(0, -velocity * Time.deltaTime, 0);
		}

		if (Input.GetKeyDown(KeyCode.Space))
		{

			//Instantiate(shoot, transform.position, transform.rotation);
		}

		//nao pode sair pela direita
		if(transform.position.x > 2.75f)
		{
			transform.position = new Vector3(2.75f, transform.position.y, 0);
		}
				
		//nao pode sair pela esquerda
		if(transform.position.x < -2.75f)
		{
			transform.position = new Vector3(-2.75f, transform.position.y, 0);
		}
		
		//nao pode sair por cima
		if(transform.position.y > 1.80f)
		{
			transform.position = new Vector3(transform.position.x, 1.80f,  0);
		}
		
		//nao pode sair por baixo
		if(transform.position.y < -2.25f)
		{
			transform.position = new Vector3(transform.position.x, -2.25f, 0);
		}
	}


}//fim classe
